
<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hệ thống quản lí thuốc online</title>
</head>
<body>
	<div id="wrapper">
		<%@ include file="../../layout/menubar.jsp"%>
		<%@ include file="../../layout/left-menu.jsp"%>
		<%@ include file="../../layout/header.jsp"%>
		<div id="page-wrapper">
			<div class="page-content">

				<!-- begin PAGE TITLE ROW -->
				<div class="row">
					<div class="col-lg-12">
						<div class="page-title">
							<ol class="breadcrumb">
								<li><i class="fa fa-dashboard"></i> <a href="">Quản lí
										thuốc</a></li>
							</ol>
						</div>
					</div>
					<!-- /.col-lg-12 -->
				</div>
				<!-- /.row -->
				<!-- end PAGE TITLE ROW -->
				<!-- begin ADVANCED TABLES ROW -->
				<div class="row">
					<div class="col-lg-12">
						<div class="portlet portlet-default">
							<div class="portlet-heading">
								<div class="portlet-title">
									<h4>Danh sách thuốc</h4>
								</div>
								<div class="clearfix"></div>
							</div>
							<div class="portlet-body">
								<div class="table-responsive">
									<div class="row form-group">
										<div class="col-sm-6 col-xs-12">
											<form action="search">
												<label>Tìm kiếm theo tên: </label> <input type="text"
													style="width: 200px; display: inline;" class="form-control"
													placeholder="Tên thuốc" name="searchKey" id="searchKey"
													value="${searchKey}">
												<button type="submit" class="btn btn-square btn-primary"
													style="width: 100px; margin-left: 20px;">Tìm</button>
											</form>
										</div>
										<div class="col-sm-6 col-xs-12">
											<form action="adminstore">
												<input type="hidden" value="listAllData" name="listAll" />
												<button type="submit"
													class="btn btn-default pull-right btn-square">
													<span class="glyphicon glyphicon-plus"></span>&nbsp;Hiển
													thị tất cả
												</button>
											</form>
										
										</div>
									</div>
									<form>
										<table id="example-table"
											class="table table-striped table-bordered table-hover table-green">
											<thead>
												<tr>
													<th>STT</th>
													<th>Tên</th>
													<th>Nhà sản xuất</th>
													<th></th>
												</tr>
											</thead>
											<tbody id='tableBody'>
												<%
													int i = 0;
												%>
												<c:forEach var="medicine" items="${medicines}">
													<tr>
														<%
															i++;
														%>
														<td><%=i%></td>
														<td>${medicine.getName()}</td>
														<td>${medicine.getDescription()}</td>
														<td><input type='checkbox' name = 'thuocCheckbox' value ="${medicine.getId()}"></td>
	<!-- 													<td> -->
	<%-- 														<c:forEach var="inGradient" items="${medicine.getGradients()}"> --%>
	<%-- 															<p>${inGradient.getName()}</p> --%>
	<%-- 														</c:forEach> --%>
	<!-- 													</td> -->
													</tr>
												</c:forEach>
											</tbody>
										</table>
									</form>
								</div>
								<!-- /.table-responsive -->
							</div>
							<!-- /.portlet-body -->
							<div class="portlet-footer">
								<button type="button" onclick="getList()"
									class="btn btn-default pull-right btn-square">
									<span class="glyphicon glyphicon-plus"></span>&nbsp;Thêm vào kho của cửa hàng
								</button>    
								<form action="list">
									<input type="hidden" value="listAllData" name="listAll" />
									<button type="submit"
										class="btn btn-default pull-right btn-square">
										<span class="glyphicon glyphicon-plus"></span>&nbsp;Kho thuốc của cửa hàng
									</button>
								</form>	
								<div class="clearfix"></div>
							</div>
							<!-- /.portlet-footer -->
						</div>
						<!-- /.portlet -->
					</div>
					<!-- /.col-lg-12 -->
				</div>
				<!-- /.row -->
			</div>
			<!-- /.page-content -->
		</div>
		<!-- /#page-wrapper -->
		<!-- end MAIN PAGE CONTENT -->
	</div>
	<!-- Modal add user -->
	<%@ include file="create.jsp"%>
	<%@ include file="edit.jsp"%>
</body>
<script type="text/javascript">
	function getList(){
		var list = document.forms[3].thuocCheckbox;
		var listId = "";
		for(var i = 0;i<list.length;i++){
 			if (list[i].checked) {
 				listId = listId + list[i].value + ",";
	        }
		}
		$.ajax({
			cache: false,
			url: "addToStore",
			data:{"listId":listId},
			success: function (data) {
			},
			error: function(data){
				alert("error");
			}
		});		
	}

</script>
</html>
